<div class='container-fluid'>
    <div class='row-fluid' id='content-wrapper'>
        <div class='span12'>
            <div class='row-fluid'>
                <div class='span12'>
                    <div class='page-header'>
                        <h2 class='pull-left'>
                            <span>【{{model.get_asks_count()}}】{{model.get_relate_url()}}</span>
                        </h2>
                        <h3 class="pull-right">
                            <button class="btn btn-warning btn-large" onclick="auto_solved_one('{{model.url}}')"
                                    name="button" type="submit"><i class="icon-magic"></i>自动解答
                            </button>
                            {% if not model.is_ignored()%}
                            <button id="set_ignore" onclick={{"set_ignore('" + model.url+
                            "')"}} class="btn btn-success btn-large" name="button">忽略</button>
                            {% else %}
                            <button id="set_ignore" onclick={{"set_ignore('" + model.url+
                            "')"}} class="btn btn-large" name="button">取消忽略</button>
                            {% endif %}
                        </h3>
                    </div>

                </div>
            </div>

            <div class='row-fluid'>
                <div class='span12 box'>
                    <div class='box-header green-background'>
                    </div>
                    <div class='box-content'>
                        <div class='row-fluid'>
                            <div class='tabbable tabs-left'>
                                <ul class='nav nav-tabs'>
                                    <li class='active'>
                                        <a data-toggle='tab' href='#lA'>
                                            请求参数
                                        </a>
                                    </li>
                                    <li>
                                        <a data-toggle='tab' href='#lB'>
                                            返回值
                                        </a>
                                    </li>
                                    <li>
                                        <a data-toggle='tab' href='#lF'>
                                            注释
                                        </a>
                                    </li>
                                    <li>
                                        <a data-toggle='tab' href='#lC'>
                                            相关数据库
                                        </a>
                                    </li>
                                    <li>
                                        <a data-toggle='tab' href='#lD'>
                                            权限
                                        </a>
                                    </li>
                                    <li>
                                        <a data-toggle='tab' href='#lE'>
                                            问题
                                        </a>
                                    </li>
                                </ul>
                                <div class='tab-content'>
                                    <div class='tab-pane active' id='lA'>
                                        <div class='box-content box-no-padding'>
                                            <div class='responsive-table'>
                                                <div class='scrollable-area'>
                                                    <table class='data-table-column-filter table table-bordered table-striped tree'
                                                           style='margin-bottom:0;'>
                                                        <thead>
                                                        <tr>
                                                            <th>
                                                                名称(路由)
                                                            </th>
                                                            <th>
                                                                类型
                                                            </th>
                                                            <th>
                                                                是否必要
                                                            </th>
                                                            <th>取值类型</th>
                                                            <th>取值范围</th>
                                                            <th>组类型</th>
                                                            <th>组</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        {% for arg in model.args.get_json()%}
                                                        {% if arg.pid >0%}
                                                        <tr class="treegrid-{{arg.id}} treegrid-parent-{{arg.pid}}">
                                                            {% else %}
                                                        <tr class="treegrid-{{arg.id}}">
                                                            {% endif %}
                                                            <td>{{arg['name']}}</td>
                                                            <td>{{arg['type']}}</td>
                                                            <td>{{arg['required']}}</td>
                                                            <td>{{arg['range_type']}}</td>
                                                            <td>{{arg['range_value']|truncate(100)}}</td>
                                                            <td>{{arg['group_type']}}</td>
                                                            <td>{{arg['group']}}</td>
                                                        </tr>
                                                        {% endfor %}
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class='tab-pane' id='lB'>
                                        <div class='box-content box-no-padding'>
                                            <div class='responsive-table'>
                                                <div class='scrollable-area'>
                                                    <table class='data-table-column-filter table table-bordered table-striped tree'
                                                    >
                                                        <thead>
                                                        <tr>
                                                            <th>
                                                                名称(路由)
                                                            </th>
                                                            <th>
                                                                类型
                                                            </th>
                                                            <th>
                                                                是否必要
                                                            </th>
                                                            <th>取值类型</th>
                                                            <th>取值范围</th>
                                                            <th>组类型</th>
                                                            <th>组</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        {% for arg in model.result.get_json()%}
                                                        {% if arg.pid >0%}
                                                        <tr class="treegrid-{{arg.id}} treegrid-parent-{{arg.pid}}">
                                                            {% else %}
                                                        <tr class="treegrid-{{arg.id}}">
                                                            {% endif %}
                                                            <td>{{arg['name']}}</td>
                                                            <td>{{arg['type']}}</td>
                                                            <td>{{arg['required']}}</td>
                                                            <td>{{arg['range_type']}}</td>
                                                            <td>{{arg['range_value']|truncate(100)}}</td>
                                                            <td>{{arg['group_type']}}</td>
                                                            <td>{{arg['group']}}</td>
                                                        </tr>
                                                        {% endfor %}
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class='tab-pane' id='lC'>
                                        <div class='box-content box-no-padding'>
                                            <div class='responsive-table'>
                                                <div class='scrollable-area'>
                                                    <table class='data-table-column-filter table table-bordered table-striped'
                                                    >
                                                        <thead>
                                                        <tr>
                                                            <th>
                                                                表
                                                            </th>
                                                            <th>
                                                                操作类型
                                                            </th>
                                                            <th>
                                                                原始内容
                                                            </th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        {% for table in model.aboutSql %}
                                                            {% for oper_type in model.aboutSql[table] %}
                                                            <tr>
                                                                <td>{{table}}</td>
                                                                <td>{{oper_type}}</td>
                                                                <td>查看原始语句</td>
                                                            </tr>
                                                            {% endfor %}
                                                        {% endfor %}
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class='tab-pane' id='lD'>
                                        <ul class=''>
                                            <li>
                                                需要登陆：{{model.need_login}}
                                            </li>
                                            <li class='separator'>
                                                要求权限：{{model.user_group}}
                                            </li>
                                        </ul>
                                    </div>
                                    <div class="tab-pane" id="lE">
                                        <div class='box-content box-no-padding'>
                                            <div class='responsive-table'>
                                                <div class='scrollable-area'>
                                                    <table class='table' style='margin-bottom:0;'>
                                                        <thead>
                                                        <tr>
                                                            <th>
                                                                问题
                                                            </th>
                                                            <th>
                                                                状态
                                                            </th>
                                                            <th>
                                                                操作
                                                            </th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        {% for que in model.get_questions()%}
                                                        <tr>
                                                            <td>{{que.get_type_desc()}}
                                                                <div class='modal hide fade'
                                                                     id=modal-example{{loop.index}}
                                                                     role='dialog' tabindex='-1'>
                                                                    <div class='modal-header'>
                                                                        <button class='close' data-dismiss='modal'
                                                                                type='button'>&times;
                                                                        </button>
                                                                        <h3>答案</h3>
                                                                    </div>
                                                                    <div class='modal-body'>
                                                                        <form class='form' id=form{{loop.index}}
                                                                              style='margin-bottom: 0;'
                                                                              action="/save_answer" method="post">
                                                                            <div class='control-group'>
                                                                                <label class='control-label'>内容</label>
                                                                                <input hidden name="que_key"
                                                                                       value={{que.key}}>
                                                                                <div class='controls'>
                                                                                    <textarea class='span12'
                                                                                              name="result">{% if que.result %}{{que.result}}{% endif %}</textarea>
                                                                                </div>
                                                                            </div>
                                                                        </form>
                                                                    </div>
                                                                    <div class='modal-footer'>
                                                                        <button class='btn' data-dismiss='modal'>
                                                                            Close
                                                                        </button>
                                                                        <button class='btn btn-primary'
                                                                                data-dismiss='modal'
                                                                                onclick="save_ans({{loop.index}})">Save
                                                                            changes
                                                                        </button>
                                                                    </div>
                                                                </div>
                                                            </td>
                                                            <td>
                                                                {% if que.solved %}
                                                                <span class='label label-success'>已解决</span>
                                                                {% else %}
                                                                <span class='label label-warning'>待解决</span>
                                                                {% endif %}
                                                            </td>
                                                            <td>
                                                                <div class='text-right'>
                                                                    {% if que.can_auto_solve() %}
                                                                    <button class="btn btn-info btn-small icon-magic" onclick=solve_one('{{que.key}}')>
                                                                        自动回答
                                                                    </button>
                                                                    {% endif %}
                                                                    <button data-toggle='modal'
                                                                            class="btn btn-warning btn-small"
                                                                            href='#modal-example{{loop.index}}'
                                                                            role='button'>修改
                                                                    </button>
                                                                    <button class="btn btn-danger btn-small"
                                                                            onclick={{"remove_ans('"+que.key+"')"}}>删除
                                                                    </button>
                                                                </div>
                                                            </td>
                                                        </tr>

                                                        {% endfor %}
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class='tab-pane' id='lF'>
                                        {% if model.comment %}

                                        {{model.comment|safe}}
                                        {% endif %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </div>
    </div>
</div>
